<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="css/adminLogin.css">
    <title>管理员登录端</title>
    <script src="js/jquery-3.7.1.min.js"></script>
    <script src="js/jquery.form.min.js"></script>
    <script src="js/adminLogin.js"></script>
    <style>
        body{
            height: 450px;
            background-image: url("imgs/skybg.jpg");
            background-size: 100% 100%;
            background-repeat: no-repeat;
            
        }

        #main-body{
            text-align: center;
            margin-top: 20%;
            input{
                width: 15%;
                font-size: 20px;
            }
        }
    </style>
</head>

<body>
    <div id="main-body">
        <h2>旅游信息管理系统</h2>
        <form id="form-login" action="AdminServlet" method="post">
            <input type="text" name="methodName" value="login" hidden>
            <p><input name="userName" type="text" placeholder="请输入账号"></p>
            <p><input name="password" type="password" placeholder="请输入密码"></p>
            <input type="submit" value="登录">
        </form>
    </div>
    <script>
        // $(function ())是文档document加载完自动调用的函数
        $(function () {
            /*
            获取form元素，调用其ajaxForm(...)方法
            内部的function(data)的data就是后台返回的数据
            */
            $("#form-login").ajaxForm(function (data) {
                    alert(data);
                    if(data == "登陆成功"){
                        console.log("true")
                        location.href="m_home_page.html";
                    }else{
                        console.log("false")
                    }
                }
            );
        });
    </script>
</body>

</html>